// @ts-ignore
/* eslint-disable */
import {request} from 'umi';
import {TroubleSystemListItem} from '@/pages/Defense/System/Trouble/data';
import {TroubleMonthCountItem} from "@/pages/Defense/System/Trouble/data";

export async function dataList(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
}) {
  return request<{
    data: TroubleSystemListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/enterprise/trouble/system/main', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

export async function monthCountDataList(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
}) {
  return request<{
    data: TroubleMonthCountItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/enterprise/trouble/system/main/item', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

export async function postCountDataList(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
}) {
  return request<{
    data: TroubleMonthCountItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/enterprise/trouble/system/main/post', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

export async function personDataList(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
}) {
  return request<{
    data: TroubleMonthCountItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/enterprise/trouble/system/main/person-list', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

export async function getTrouble(param: { troubleId?: number }): Promise<{ data: TroubleBody }> {
  console.log(param);
  return request(`/v2/enterprise/trouble/${param.troubleId}`, {method: 'GET'});
}

export async function addTrouble(param: TroubleBody): Promise<{ data: number }> {
  return request('/v2/enterprise/trouble', {method: 'TROUBLE', data: param});
}

export async function updateTrouble(param: TroubleBody): Promise<{ data: number }> {
  return request('/v2/enterprise/trouble', {method: 'PUT', data: param});
}

export async function removeTrouble(data: number[], options?: { [key: string]: any }) {
  return request<Record<string, any>>(`/v2/enterprise/trouble/` + data.join(), {
    method: 'DELETE',
    ...(options || {}),
  });
}
